-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use --file-name to detect syntax highlighting #892
Conversation
(also tested manually) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution.
3cffcc5
to
ee09461
Compare
Rebased and fixed merge conflicts. |
src/assets.rs
Outdated
(None, InputFile::StdIn(Some(file_name))) => self | ||
.syntax_set | ||
.find_syntax_by_extension(file_name.to_str().unwrap()) | ||
.or_else(|| { | ||
self.syntax_set.find_syntax_by_extension( | ||
Path::new(file_name) | ||
.extension() | ||
.and_then(|x| x.to_str()) | ||
.unwrap_or(""), | ||
) | ||
}) | ||
.or(String::from_utf8(reader.first_line.clone()) | ||
.ok() | ||
.and_then(|l| self.syntax_set.find_syntax_by_first_line(&l))), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like the fact that the whole logic from the (None, InputFile::Ordinary(ofile))
case above is repeated here. We should extract this into a separate method or try to move both cases into the same match arm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, that makes sense. I chose the helper method approach.
1e59b36
to
09aef24
Compare
Thank you for the updates! |
Closes #891